﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ToolsCatalog.Model
{
    public class Catalog : ToolBase
    {
        Dictionary<int,Tool> toolsDic;
        public Catalog()
        {
            ToolsDic = new Dictionary<int, Tool>();
        }

        
        public List<Tool> ToolsDicL
        {
            get { return new List<Tool>(toolsDic.Values); }
        }
        public Dictionary<int,Tool> ToolsDic
        {
            get { return toolsDic; }
            set { toolsDic = value; }
        }
        public void BildTree()
        {
            foreach (Tool t in ToolsDic.Values)
            {
                
                foreach (Part p in t.Parts)
                {
                    p.Tool = toolsDic[p.Id];
                    t.Tools.Add(p.Tool);
                }
            }
        }
        public override string ToString()
        {
            string str = "Catalog  ";
            foreach (Tool t in toolsDic.Values)
            {
                str += t.ToString();
            }
            return str;
        }
    }
}
